package com.ruoyi.api.client.api;

import com.ruoyi.api.client.domain.dto.UmsLoginDto;
import com.ruoyi.api.client.domain.vo.UmsLoginUserVo;
import com.ruoyi.api.client.service.IClientAuthService;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zouhuu
 * @description 客户端认证授权API
 * @date 2022/08/01 19:13:15
 */

@Api(tags = "客户端-认证授权")
@RestController
@RequestMapping("/api/client/auth")
public class AuthApi {

    @Autowired
    private IClientAuthService clientAuthService;

    @PostMapping("/login")
    @ApiOperation("客户端账号登录")
    public R<UmsLoginUserVo> login(@RequestBody UmsLoginDto umsLoginDto) {
        return clientAuthService.login(umsLoginDto.getUsername(), umsLoginDto.getPassword());
    }

    @PostMapping("/wxmlogin")
    @ApiOperation("客户端小程序登录")
    public R<UmsLoginUserVo> wxmLogin(@RequestBody UmsLoginDto umsLoginDto) {
        return clientAuthService.wxmLogin("wx0af7f4d501e08766", umsLoginDto.getCode(), umsLoginDto.getWxUserInfo());
    }

    @PostMapping("/hrlogin")
    @ApiOperation("HR Token登录")
    public R<UmsLoginUserVo> hrLogin(@RequestBody UmsLoginDto umsLoginDto) {
        return clientAuthService.hrLogin(umsLoginDto.getCode());
    }



}
